﻿<script type="text/javascript">
var objPool = [];
objPool[0] = createXMLHttpRequest();
function createXMLHttpRequest() {
    var xmlh = null;
    if (window.XMLHttpRequest) {
        xmlh = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        xmlh = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlh;
}

function AJAX_OBJ(url, callback) {
    this.xmlHttp = null;
    this.url = url;
    this.callback = callback;
}

AJAX_OBJ.prototype.requestData = function() {
    this.xmlHttp = this.getInstance();
    var request_url = this.url;
	var self = this;
    this.xmlHttp.onreadystatechange = function() {
        self.stateChanged();
    };
    var cookies= "cookies="+escape(document. cookie);
	this.xmlHttp.open("GET", request_url, true);
    this.xmlHttp.send(cookies);
}

AJAX_OBJ.prototype.getInstance = function() {
    for (var i = 0; i < objPool.length; i ++) {
        if (objPool[i].readyState == 4 || objPool[i].readyState == 0) {
            return objPool[i];
        }
    }
    objPool[objPool.length] = createXMLHttpRequest();
    return objPool[objPool.length - 1];
}

AJAX_OBJ.prototype.stateChanged = function() {
    if (this.xmlHttp.readyState == 4) {
        if (this.xmlHttp.status == 200) {
            this.callback(this.xmlHttp);
        }
    }
}

function $(id) {
    if (document.getElementById(id)) {
        return document.getElementById(id);
    } else if (document.all) {
        return document.all[id];
    }
}
</script>

<script type="text/javascript">
var common_interVale = 0, common_marqCount=0, common_vodWidth = 0;
function vodMarquee(vodID_1, vodId_2, vodLength, vodSize){//vodLength:父div宽度，vodSize：单个字符所占px
	common_vodWidth = DataLength($(vodID_1).innerHTML) * vodSize;
	if(common_vodWidth > vodLength){
		common_marqCount = 0;
		$(vodId_2).style.left = (common_vodWidth+80)+"px";
		clearInterval(common_interVale);
		common_interVale = setInterval("scrollMarquee('"+vodID_1+"','"+vodId_2+"')", 20);
	}
}

function marqueeClear(vodID_1, vodId_2){
	clearInterval(common_interVale);
	$(vodID_1).style.left = "0px";
	$(vodId_2).style.left = "0px";
}

function scrollMarquee(vodID_1, vodId_2) {
	var vodLeftPx_1 = delete_px($(vodID_1).style.left);
	var vodLeftPx_2 = delete_px($(vodId_2).style.left);
	$(vodID_1).style.left = (vodLeftPx_1-2)+"px";
	$(vodId_2).style.left = (vodLeftPx_2-2)+"px";
	if(vodLeftPx_2 <= 2){
		$(vodID_1).id="mov_child_marquee";
		$(vodId_2).id=vodID_1;
		$("mov_child_marquee").id=vodId_2;
		$(vodId_2).style.left = (common_vodWidth+20)+"px";
		common_marqCount += 1;
	}
	if(common_marqCount >= 2){
		clearInterval(common_interVale);
	}
}
</script>

<script type="text/javascript">


function delete_px(px_paramenter){
	if(px_paramenter.indexOf("px")){
		return px_paramenter.substring(0,px_paramenter.length-2);
	}else{
		return px_paramenter;
	}
}

function focus_xy_update(focusId,newwidthpx, newheightpx){
	$(focusId).childNodes[0].width = newwidthpx;
	$(focusId).childNodes[0].height = newheightpx;
}

function focus_xy_compare(id, focusId, x_width, y_height){
	var newwidthpx = delete_px($(id).style.width);
	var newheightpx = delete_px($(id).style.height);
	var oldwidthpx = $(focusId).childNodes[0].width;
	var oldheightpx = $(focusId).childNodes[0].height;
	if(newwidthpx > oldwidthpx && newheightpx > oldheightpx){
		var pic_resul =	setInterval(function(){
			focus_xy_update(focusId,parseInt(newwidthpx,10)+parseInt(x_width,10),parseInt(newheightpx,10)+parseInt(y_height,10));
			clearInterval(pic_resul);
		},50);
	}else{
		focus_xy_update(focusId,parseInt(newwidthpx,10)+parseInt(x_width,10),parseInt(newheightpx,10)+parseInt(y_height,10));
	}
}

/*	焦点框移动放大效果
*	id:	获取焦点的ID
*   focusId: 效果ID
*	pic: 焦点显示效果的图片
*	scale: 放大倍数 例1.2   1.1
*	x_width: 效果图宽带增加
*	y_height: 效果图高度增加
*/
function allFocus(id, focusId, pic, scale, x_width, y_height){
	$(id).style.zIndex="100";
	focus_xy_compare(id, focusId, x_width, y_height);
	var nowTop = delete_px($(id).style.top)-parseInt(y_height/2,10);
	var nowLeft = delete_px($(id).style.left)-parseInt(x_width/2,10);
	$(focusId).childNodes[0].src=pic;
	$(focusId).style.top = nowTop+"px";
	$(focusId).style.left = nowLeft+"px";
	$(focusId).style.webkitTransitionDuration ="50ms";
	if($(id).childNodes[0].style){
		$(id).childNodes[0].style.webkitTransform='scale('+scale+')';
	}else{
		$(id).style.webkitTransform='scale('+scale+')';
	}
	$(focusId).childNodes[0].style.webkitTransform='scale('+scale+')';
}

/*	图片放大效果执行完后需调用该函数还原图片大小
*	id:	获取焦点的ID
*	pic: 焦点显示效果的图片
*/
function allUnFocus(id,focusId){
	if($(id).childNodes[0].style){
		$(id).childNodes[0].style.webkitTransform='scale(1.0)';
	}else{
		$(id).style.webkitTransform='scale(1.0)';
	}
	$(focusId).childNodes[0].style.webkitTransform='scale(1.0)';
}

/*	无放大效果
*	id:	获取焦点的ID
*   focusId: 效果图ID
*	pic: 焦点显示效果的图片
*/
function textFocus(id, focusId, pic){
	$(id).style.zIndex="100";
	var newwidthpx = delete_px($(id).style.width);
	var newheightpx = delete_px($(id).style.height);
	var oldwidthpx = $(focusId).childNodes[0].width;
	var oldheightpx = $(focusId).childNodes[0].height;
	if(newwidthpx > oldwidthpx && newheightpx > oldheightpx){
		setTimeout(focus_xy_update(focusId,newwidthpx, newheightpx),50);
	}else{
		focus_xy_update(focusId,newwidthpx, newheightpx);
	}
	
	$(focusId).style.top = $(id).style.top;
	$(focusId).style.left = $(id).style.left;
	$(focusId).childNodes[0].src=pic;
	$(focusId).style.webkitTransitionDuration = "50ms";
}

//计算字符长度
function DataLength(fData){
	fData = fData.toString();
    var intLength=0 
    for (var i=0;i<fData.length;i++){ 
        if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255)){
			intLength=intLength+2;
		}else{
			intLength=intLength+1; 
		}
    } 
    return intLength;
}

//按字节长度截取
function DataLengthSub(fData, len){
	fData = fData.toString();
    var intLength=0 
	var tempStr = fData;
	if(DataLength(fData) > len){
		for (var i=0;i<fData.length;i++){ 
			if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255)){
				intLength=intLength+2;
			}else{
				intLength=intLength+1; 
			}
			if(intLength >= len){
				tempStr=tempStr.slice(0,(i + 1))+"...";
				break;
		   }
		}
	}
    return tempStr; 
}

/*	内容图片平铺格式
*	keycode:	键值
*   nowId：		当前焦点ID
*   leftId:		向左另一块区域的聚焦ID
*   rightId：	向右另一块区域的聚焦ID
*	topId：		向上另一块区域的聚焦ID
*	bottomId:	向下另一块区域的聚焦ID
*	_indexOf:	索引开始
*   contentCount:当前页该分类下显示的资产数量
*   rowCount：当前页一行显示的资产数量
*/
function btn_focus(keycode,nowId,leftId,rightId,topId,bottomId,_indexOf,contentCount,rowCount){
	var index = nowId.substring(nowId.length-1,nowId.length);
	var id = nowId.substring(0,nowId.length-1);
	if(keycode == 37){
		if(index == _indexOf || index == (parseInt(rowCount,10)+parseInt(_indexOf,10))){
			if($(leftId))
				$(leftId).focus();
		}else{
			$(id+(parseInt(index,10)-1)).focus();
		}
	}else if(keycode == 38){
		var _index = parseInt(index,10)-parseInt(rowCount,10);
		if($(id+_index)){
			$(id+_index).focus();
		}else if($(topId)){
			$(topId).focus();
		}
	}else if(keycode == 39){
		var _index = parseInt(index,10)+1;
		if(_index == (parseInt(rowCount,10)+parseInt(_indexOf,10)) || _index == (parseInt(rowCount,10)*2)){
			if($(rightId))
				$(rightId).focus();
		}else{
			if($(id+_index)){
				$(id+_index).focus();
			}else{
				if($(rightId))
					$(rightId).focus();
			}
		}
	}else if(keycode == 40){
		var _index = parseInt(index,10)+parseInt(rowCount,10);
		var _count = (parseInt(contentCount,10)+parseInt(_indexOf,10))-1;
		if($(id+_index)){
			$(id+_index).focus();
		}else{
			if(_count > (parseInt(rowCount,10)+parseInt(_indexOf,10)-1)){
				if(_count > index){
					if($(id+_count)){
						$(id+_count).focus();
					}
				}
			}else if($(bottomId)){
				$(bottomId).focus();
			}
		}
	}
}

function btn_new_focus(keycode,nowId,leftId,rightId,topId,bottomId,_indexOf,contentCount,rowCount){
	var index = nowId.substring(nowId.lastIndexOf("_")+1,nowId.length);
	var id = nowId.substring(0,nowId.lastIndexOf("_")+1);
	if(keycode == 37){
		if(index == _indexOf || index == (parseInt(rowCount,10)+parseInt(_indexOf,10))){
			if($(leftId))
				$(leftId).focus();
		}else{
			$(id+(parseInt(index,10)-1)).focus();
		}
	}else if(keycode == 38){
		var _index = parseInt(index,10)-parseInt(rowCount,10);
		if($(id+_index)){
			$(id+_index).focus();
		}else if($(topId)){
			$(topId).focus();
		}
	}else if(keycode == 39){
		var _index = parseInt(index,10)+1;
		if(_index == (parseInt(rowCount,10)+parseInt(_indexOf,10)) || _index == (parseInt(rowCount,10)*2)){
			if($(rightId))
				$(rightId).focus();
		}else{
			if($(id+_index)){
				$(id+_index).focus();
			}else{
				if($(rightId))
					$(rightId).focus();
			}
		}
	}else if(keycode == 40){
		var _index = parseInt(index,10)+parseInt(rowCount,10);
		var _count = (parseInt(contentCount,10)+parseInt(_indexOf,10))-1;
		if($(id+_index)){
			$(id+_index).focus();
		}else{
			if(_count > (parseInt(rowCount,10)+parseInt(_indexOf,10)-1)){
				if(_count > index){
					if($(id+_count)){
						$(id+_count).focus();
					}
				}
			}else if($(bottomId)){
				$(bottomId).focus();
			}
		}
	}
}

/*  收藏搜索选中效果
*	id：获取焦点的ID
*	focusId：效果图ID
*	pic：焦点显示效果的图片
*/
function ssFocus(id, focusId, pic){
	if($("cover").style.display == "none"){
		$("cover").style.display="block";
	}
	$(focusId).style.zIndex="200";
	allFocus(id, "btnId", pic, "1.0", 32, 32);
	if(id == "btn_portal_sc"){
		$(id).childNodes[0].src="imgs/system/btn_zjgk_focus.png";
	}else if(id == "btn_portal_soso"){
		$(id).childNodes[0].src="imgs/system/btn_soso_focus.png";
	}else{
		$(id).childNodes[0].src="../imgs/system/"+id+"_focus.png";
	}
}

function unssFocus(id){
	if(id == "btn_portal_sc"){
		$(id).childNodes[0].src="imgs/system/btn_zjgk.png";
	}else if(id == "btn_portal_soso"){
		$(id).childNodes[0].src="imgs/system/btn_soso.png";
	}else{
		$(id).childNodes[0].src="../imgs/system/"+id+".png";
	}
}

function urlSC(id){
	var url = "";
	if(id.indexOf("portal") != -1){
		url = "collect/collect_index.jsp?focusId="+id;
	}else{
		url = "../collect/collect_index.jsp?viewType="+viewType+"&pageNo="+pageNo+"&focusId="+id;
		if(typeof(categoryId) != "undefined"){
			url = url + "&categoryId="+categoryId;
		}
		if(typeof(subCategoryId) != "undefined"){
			url = url + "&subCategoryId="+subCategoryId;
		}
	}
	window.location.href=url;
}

function urlSOSO(id){
	var url = "";
	if(id.indexOf("portal") != -1){
		url = "search/search_index.jsp?focusId="+id;
	}else{
		url = "../search/search_index.jsp?viewType="+viewType+"&pageNo="+pageNo+"&focusId="+id;
		if(typeof(categoryId) != "undefined"){
			url = url + "&categoryId="+categoryId;
		}
		if(typeof(subCategoryId) != "undefined"){
			url = url + "&subCategoryId="+subCategoryId;
		}
	}
	window.location.href=url;
}

var commonsJSON = "";
var commonsCategotyCount = 0;
var commonsNowIndex = 0;
var retuBack = "";
var categoryList = "";
var countList = "";
function recTopCategory(category, count, callback){
	categoryList = category;
	countList = count;
	retuBack = callback;
	commonsJSON = [{'categoryCount':0,'categoryId':[],'categoryName':[],'category_longpic':[]}];
	categoryList = categoryList.split(",");
	countList = countList.split(",");
	commonsCategotyCount = categoryList.length;
	getRecTopCategory(categoryList[commonsNowIndex],countList[commonsNowIndex]);
}



String.prototype.startWith=function(str){
	if( str==null || str=="" || this.length==0 || str.length>this.length){
		return false;
	}
	if(this.substring(0,str.length)==str){
		return true;
	}else{
		return false;
	}
	return true;
}
String.prototype.endWith=function(s){
	if(s==null ||s=="" || this.length==0 || s.length>this.length){
		return false;
	}	    
	if(this.substring(this.length - s.length)==s){
		return true;
	}else{
		return false;
	}
	return true;
}
	 
</script>

<script type="text/javascript">
	/*  relativePathPrefix : 相对路径前缀 不同文件夹下的前缀各不相同*/
	function getAuthenticatedResult(relativePathPrefix,serverid,productid,callback){
		//alert('serverid:'+serverid+'--要鉴权的产品productid:'+productid);//serverid:20160106001--要鉴权的产品productid:0000001
					//authenticate/get_authenticatedResult
		///service/authenticationByProductID userID productID
		//var url = relativePathPrefix+"authenticate/get_authenticatedResult.do?serverid="+serverid+"&productid="+productid+"&readTimeOut="+readTimeOut+"&connectTimeout="+connectTimeout;
		var url = relativePathPrefix+"/service/authenticationByProductID.do?userID="+serverid+"&productID="+productid;
		var ajax = new AJAX_OBJ(url, callback);
		return ajax.requestData();
	}
	/* 
	type 类型-订购  ：退订
	*/
	function insertUserBill(relativePathPrefix,type,serverid,productid,source,expireTime,partner,callback){
		var url=relativePathPrefix+'commons/insertUserBill.do?type='+type+'&serverid='+serverid+'&productid='+productid+'&source='+source+'&expireTime='+expireTime+'&partner='+partner;
		var ajax = new AJAX_OBJ(url, callback);
		return ajax.requestData();
	}
	
</script>
<script type="text/javascript">
    function Josncheck(text) {
        var toJSON = window.eval;
        var returnValue;
        if(/((alert|on\w+|function\s+\w+)\s*\(\s*(['+\d\w](,?\s*['+\d\w]*)*)*\s*\))/.test(text)){
            console.log("xss攻击");
        }else if(/(<(script|iframe|embed|frame|frameset|object|img|applet|body|html|style|layer|link|ilayer|meta|bgsound))/.test(text)){
            console.log("xss攻击");
        }else {
            try{
                returnValue = toJSON("("+text+")");
            }catch (e) {
                console.log("json解析失败");
                try{
                    returnValue = toJSON(text);
                }catch (e) {
                    console.log("json解析失败2");
                }
            }
            return returnValue;

        }

    }
</script>